home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr49
/
352_01.zip
/
VECSUM.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-10
|
561b
|
27 lines
// vecsum.cpp - sum elements of vector between 2 endpoints
#include <stdlib.h>
#include <alloc.h>
#include <string.h>
#include "wtwg.h"
#include "dblib.h"
#include "vector.h"
float sum (Vector& vec, int n1, int n2 )
// sum between point1 and point2 (friend function of Vector)
// if point2 == -1, sums to end of vec
{
float s=0;
if ( n2<0 ) n2 = vec.n;
float *vv =vec.v;
for ( int i=n1; i<n2; ++i )
{
s+= vv[i];
}
return (s);
}
//----------------------------- end VECSUM.CPP --------------------------